%{
#include<stdio.h>
#include<stdlib.h>
#include "operation.h"

extern int yylex();
extern void executeSQL();
void yyerror(char * s);
%}

%union{
    char * name;
    double d;
    int number;
    char * string;
    int cp;
}

%token HELPSQL CREATEDATABASESQL SHOWDATABASESQL DESCTABLESQL GT GE EQ LT LE NE

%token <number> NUMBER
%token <string> CHARACTER
%token <d> DOUBLE
%token <string> ID
%token <name> CREATE INSERT SELECT DELETE UPDATE DATABASES DATABASE INTO VALUES WHERE AND OR TABLE SHOW DESC DELIMETER HELP NUL NOT IS
%token <cp> CP


%start sql

%%

sql: 
| HELP DELIMETER { executeSQL(NULL,HELP);} 
| CREATE DATABASE ID DELIMETER{ executeSQL($3,CREATEDATABASESQL); }
| SHOW DATABASES DELIMETER {executeSQL(NULL,SHOWDATABASESQL);}
| DESC ID {executeSQL($2,DESCTABLESQL);} 

%%

void yyerror(char * s){
    printf("syntax error: %s!",s);
    return;
}